package com.hnevc.anroiduiclassone5;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

/**
 * Created by Administrator on 2018/6/13.
 */

public class MyDialog extends Dialog{
    interface  Oncharge{
        void  updateAmount(String amount);
    }
    Oncharge oncharge;
    String carNumber;
    TextView mTvMessage;
    Button mBtucharge;
    EditText ent;
    public MyDialog(@NonNull Context context) {
        super(context);
    }
    public MyDialog(@NonNull Context context,String carNumber) {
        super(context);
        this.carNumber=carNumber;
    }
    public MyDialog(@NonNull Context context,String carNumber,Oncharge oncharge) {
        super(context);
        this.carNumber=carNumber;
        this.oncharge=oncharge;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.my_dialog);
        mTvMessage=findViewById(R.id.tv_carnumber);
        mTvMessage.setText(carNumber);
        ent=findViewById(R.id.et_amount);
        mBtucharge=findViewById(R.id.btn_charge);
        mBtucharge.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               String amount=ent.getText().toString();
                 oncharge.updateAmount(amount);
                 dismiss();
            }
        });
    }
}
